package com.wushi.lenovo.asia5b.app_di.profile.presenter;

import com.mvp.helper.WCallBack;
import com.wushi.lenovo.asia5b.app_di.other.presenter.CodePresenter;
import com.wushi.lenovo.asia5b.app_di.profile.mvpview.ChangeMobileActivityView;
import com.wushi.lenovo.asia5b.app_http.ApiService;
import com.wushi.lenovo.asia5b.app_model.other.CacheType;
import com.wushi.lenovo.asia5b.app_model.profile.CountryModel;
import com.wushi.lenovo.asia5b.app_utils.helper.CacheHelper;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

/**
 * Created by zhangyuncai on 2018/12/6.
 */
public class ChangeMobileActivityPresenter extends CodePresenter<ChangeMobileActivityView> {


    @Inject
    public ChangeMobileActivityPresenter(ApiService apiService) {
        super(apiService);
    }

    //获取国家列表
    public void getCountrys() {
        CacheHelper.getCountrys(new WCallBack<List<CountryModel>>() {
            @Override
            public void callback(List<CountryModel> countryModels) {
                getView().getCountrysResult(countryModels);
            }
        }, CacheType.LOCAL);
//        baseSubscribe(apiService.getCountrys(), listResultModel -> {
//            getView().getCountrysResult(listResultModel.getData());
//        });
    }

    public void sendCode(String mobile_num, String calling_code) {
        super.sendCode(mobile_num,calling_code,CodeType.CHANGE_MOBILE);
    }

    public void changeMobile(Map<String, Object> map) {
        baseSubscribe(apiService.updataPhone(map), resultModel -> {
            getView().changeMobileResult(resultModel,map);
        });
    }


}